package com.gregbugaj.nscaffold.generator.artifact;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class FileArtifact extends Artifact {

	@Override
	public ArtifactType getType() {
		return ArtifactType.FILE;
	}

	@Override
	public void render() {
		String filename=getName();
		File file=new File(root, filename);
		try {
			String content=getContent();
			BufferedOutputStream bos=new BufferedOutputStream(new FileOutputStream(file));
			bos.write((content!=null)?content.getBytes():"".getBytes());
			bos.close();
			
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}

	@Override
	public File getOutputRoot() {	 
		return null;
	}

}
